package com.hiultra.archive.controller;

import java.rmi.ServerException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveBoxMove;
import com.hiultra.archive.service.IArchiveBoxMoveService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 盒移位Controller
 *
 * @author 派大星
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/archive/ArchiveBoxMove")
public class ArchiveBoxMoveController extends BaseController
{
    @Autowired
    private IArchiveBoxMoveService archiveBoxMoveService;

    /**
     * 查询盒移位列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveBoxMove archiveBoxMove)
    {
        startPage();
        List<ArchiveBoxMove> list = archiveBoxMoveService.selectArchiveBoxMoveList(archiveBoxMove);
        return getDataTable(list);
    }

    /**
     * 导出盒移位列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:export')")
    @Log(title = "盒移位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveBoxMove archiveBoxMove)
    {
        List<ArchiveBoxMove> list = archiveBoxMoveService.selectArchiveBoxMoveList(archiveBoxMove);
        ExcelUtil<ArchiveBoxMove> util = new ExcelUtil<ArchiveBoxMove>(ArchiveBoxMove.class);
        util.exportExcel(response, list, "盒移位数据");
    }

    /**
     * 获取盒移位详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(archiveBoxMoveService.selectArchiveBoxMoveById(id));
    }

    /**
     * 新增盒移位
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:add')")
    @Log(title = "盒移位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveBoxMove archiveBoxMove)
    {
        return toAjax(archiveBoxMoveService.insertArchiveBoxMove(archiveBoxMove));
    }

    /**
     * 修改盒移位
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:edit')")
    @Log(title = "盒移位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveBoxMove archiveBoxMove)
    {
        return toAjax(archiveBoxMoveService.updateArchiveBoxMove(archiveBoxMove));
    }

    /**
     * 删除盒移位
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:remove')")
    @Log(title = "盒移位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(archiveBoxMoveService.deleteArchiveBoxMoveByIds(ids));
    }
    /**
     * 根据任务id查询盒移位信息详情
     * @param taskId
     * @return
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:query')")
    @GetMapping(value = "/selectArchiveBoxMoveByTaskId/{taskId}")
    public AjaxResult selectArchiveBoxMoveByTaskId(@PathVariable("taskId") String taskId)
    {
        return AjaxResult.success(archiveBoxMoveService.selectArchiveBoxMoveByTaskId(taskId));
    }

    /**
     * 批量修改修改盒移位
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:editarchiveBoxMoveList')")
    @Log(title = "批量修改修改盒移位", businessType = BusinessType.UPDATE)
    @PostMapping("/editarchiveBoxMoveList")
    public AjaxResult editarchiveBoxMoveList(@RequestBody List<ArchiveBoxMove> archiveBoxMoveList)
    {
        return toAjax(archiveBoxMoveService.updateArchiveBoxMoveList(archiveBoxMoveList,getUsername()));
    }

    /**
     * 移位完成接口
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxMove:endArchiveBoxMoveList')")
    @Log(title = "批量修改修改盒移位", businessType = BusinessType.UPDATE)
    @PostMapping("/endArchiveBoxMoveList")
    public AjaxResult endArchiveBoxMoveList(@RequestBody List<ArchiveBoxMove> archiveBoxMoveList) throws ServerException {
        return archiveBoxMoveService.endArchiveBoxMoveList(archiveBoxMoveList);
    }

}
